Test Series - java script

Test Number 14/92

Q: The four kinds of class members are ________
A. Instance methods, Instance fields, Static method, Dynamic method
B. Instance fields, Instance methods, Class fields, Class methods
C. Instance fields, Non-instance fields, Dynamic methods, Global methods
D. Global methods, Local methods, Dynamic methods, Static methods
Solution: A class mainly contains data members and associated member functions. Therefore over all different kinds of class members are instance field, instance method, class fields and class methods.
Q: Different kinds of the object involved in a class definition are ________
A. Public object, Private object, Protected object
B. Constructor object, Function object, Destructor object
C. Constructor object, Prototype object, Instance object
D. Instance method, Static object, Dynamic object
Solution: In JavaScript, there are three different objects involved in any class definition, and the properties of these three objects act like different kinds of class members namely, Constructor object, Prototype object, and Instance object.
Q: The object whose properties are inherited by all instances of the class, and properties whose values are functions behaving like instance methods of the class, is ________
A. Instance object
B. Constructor object
C. Destructor object
D. Prototype object
Solution: The properties of the prototype object are inherited by all instances of the class, and properties whose values are functions behave like instance methods of the class.
Q: Which variables are used internally in object methods and are also globally visible?
A. Object properties
B. Variable properties
C. Method properties
D. Internal properties
Solution: The variable properties are usually variables that are used internally in the object’s methods, but can also be globally visible variables that are used through the page.
Q: The class that represents the regular expressions is ________
A. RegExpObj
B. RegExpClass
C. RegExp
D. StringExp
Solution: Regular expression is an object that describes a pattern of characters. The JavaScript RegExp class represents regular expressions, and both string and RegExp define methods that use regular expressions.
Q: The different variant of Date() constructor to create date object is/are ___________
i. new Date(date)
ii. new Date(milliseconds)
iii. new Date(date string)
iv. new Date(year, month, date[hour, minute, second, millisecond])
A. i, ii and iii only
B. ii, iii and iv only
C. i, ii and iv only
D. i, ii, iii and iv
Solution: Date() is a predefined object type in javascript. There are 4 ways to create a new date object:new Date(), new Date(year, month, day, hours, minutes, seconds, milliseconds), new Date(milliseconds), new Date(date string).
Q: Which is the correct code that returns a complex number that is the complex conjugate of this one?
A. Complex.prototype.conj = function() { return new Complex(this.r, -this.i); };
B. Complex.prototype.conj = function() { return Complex(this.r, -this.i); };
C. Complex.prototype.conj = function() { return (this.r, -this.i); };
D. Complex.prototype.conj = function() { new Complex(this.r, -this.i); };
Solution: Object.prototype.constructor specifies the function that creates the object prototype. The above code snippet returns a complex number that is the complex conjugate of this one.
Q: How can we make methods available on all objects?
A. Object.add(methods)
B. Object.methods(add)
C. Object.add.methods(…)
D. Object.prototype
Solution: It is possible to add methods to Object.prototype, making them available on all objects. This is not recommended, however, because prior to ECMAScript5, there is no way to make these add-on methods non enumerable, and if you add properties to Object.prototype, those properties will be reported by all for/in loops.
Q: What is the procedure to add methods to HTMLElement so that they will be inherited by the objects that represent the HTML tags in the current document?
A. HTMLElement.prototype(…)
B. HTMLElement.prototype
C. HTML.addmethods()
D. HTML.elements(add)
Solution: It is implementation-dependent whether classes defined by the host environment (such as the web browser) can be augmented using Object.prototype. In many web browsers, for example, you can add methods to HTMLElement.prototype and those methods will be inherited by the objects that represent the HTML tags in the current document.
Q: You can refresh the webpage in JavaScript by using ________
A. window.reload
B. location.reload
C. window.refresh
D. page.refresh
Solution: The reload method is used to reload the current file. User can reload the page from the server through location. Reload.

You Have Score    /10